package com.util;

import java.util.List;

/**
 * 分页助手
 * @param <T>
 */
public class PageAssistant<T> {

    //总记录
    private Integer total;
    //总页数
    private Integer pageCount;
    //当前页
    private Integer curPage;
    //每页显示
    private Integer pageSize;

    /* 页面内容集合 */
    private List<T> rows;

    @Override
    public String toString() {
        return "PageAssistant{" +
                "total=" + total +
                ", pageCount=" + pageCount +
                ", curPage=" + curPage +
                ", pageSize=" + pageSize +
                ", rows=" + rows +
                '}';
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
        setPageCount();
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount() {
        this.pageCount = total / pageSize;
        if (total % pageSize != 0){
            pageCount++;
        }
    }

    public Integer getCurPage() {
        return curPage;
    }

    public void setCurPage(Integer curPage) {
        this.curPage = curPage;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}
